package com.wcy.constant;

/**
 * <p>Title:LoginConstant.java</p >
 * <p>Description: </p >
 * <p>Copyright: 公共服务与应急管理战略业务本部 Copyright(c)2020</p >
 * <p>Date:2021/9/13 19:22</p >
 *
 * @author wcy (wangchaoyanga@mail.taiji.com.cn)
 * @version 1.0
 */

/**
 * 登录的常量
 */
public class LoginConstant {

    /**
     * 后台管理人员
     */
    public static final String ADMIN_TYPE="admin_type";

    /**
     * 普通会员
     */
    public static final String MEMBER_TYPE="member_type";

    /**
     * 使用id查询后台人员用户名
     */
    public static final String QUERY_ADMIN_USERNAME=
                                    "select `username` from sys_user where id = ?";

    /**
     * 使用id查询会员用户名
     */
    public static final String QUERY_MEMBER_USERNAME=
                                    "select `username` from `user` where id = ?";

    /**
     * token的刷新
     */
    public static  final  String REFRESH_TOKEN = "refresh_token" ;

    /**
     * 使用用户名查询用户
     */
    public static final String QUERY_ADMIN_SQL =
            "SELECT `id` ,`username`, `password`, `status` FROM sys_user WHERE username = ? ";

    /**
     * 查询用户的角色Codes
     */
    public static final String QUERY_ROLE_CODE_ID_SQL =
            "SELECT `code` FROM sys_role LEFT JOIN sys_user_role ON sys_role.id = sys_user_role.role_id WHERE sys_user_role.user_id= ?";

    /**
     * 查询所有权限名称
     */
    public static final String QUERY_ALL_PERMISSIONS =
            "SELECT `name` FROM sys_privilege";

    /**
     * 对于非管理员用户 需要根据 userId -> roleIds -> privilegeIds -> privilegeNames
     */
    public static final String QUERY_PERMISSION_SQL =
            "SELECT * FROM sys_privilege LEFT JOIN sys_role_privilege ON sys_role_privilege.privilege_id = sys_privilege.id LEFT JOIN sys_user_role  ON sys_role_privilege.role_id = sys_user_role.role_id WHERE sys_user_role.user_id = ?";

    /**
     * 超级管理员的角色Code
     */
    public static final String ADMIN_ROLE_CODE="ROLE_ADMIN";

    /**
     * 会员查询SQL
     */
    public static final String QUERY_MEMBER_SQL =
            "SELECT `id`,`password`, `status` FROM `user` WHERE mobile = ? or email = ? ";
}
